//+-----------------------------------------------------------------------------
//| Included files
//+-----------------------------------------------------------------------------
#include "Texture.h"

//+-----------------------------------------------------------------------------
//| Constructor
//+-----------------------------------------------------------------------------
TEXTURE::TEXTURE()
{
	TextureId = 0;
	FileName = "";
	
	Width = 0;
	Height = 0;
	RealWidth = 0;
	RealHeight = 0;
}


//+-----------------------------------------------------------------------------
//| Destructor
//+-----------------------------------------------------------------------------
TEXTURE::~TEXTURE()
{
	Clear();
}


//+-----------------------------------------------------------------------------
//| Clears the texture
//+-----------------------------------------------------------------------------
VOID TEXTURE::Clear()
{
	TextureReference.Detach();

	TextureId = 0;
	FileName = "";

	Width = 0;
	Height = 0;
	RealWidth = 0;
	RealHeight = 0;
}


//+-----------------------------------------------------------------------------
//| Returns the texture id
//+-----------------------------------------------------------------------------
INT TEXTURE::GetTextureId() CONST
{
	return TextureId;
}


//+-----------------------------------------------------------------------------
//| Returns the filename
//+-----------------------------------------------------------------------------
std::string TEXTURE::GetFileName() CONST
{
	return FileName;
}


//+-----------------------------------------------------------------------------
//| Return the width
//+-----------------------------------------------------------------------------
INT TEXTURE::GetWidth() CONST
{
	return Width;
}


//+-----------------------------------------------------------------------------
//| Return the height
//+-----------------------------------------------------------------------------
INT TEXTURE::GetHeight() CONST
{
	return Height;
}


//+-----------------------------------------------------------------------------
//| Return the read width
//+-----------------------------------------------------------------------------
INT TEXTURE::GetRealWidth() CONST
{
	return RealWidth;
}


//+-----------------------------------------------------------------------------
//| Return the width
//+-----------------------------------------------------------------------------
INT TEXTURE::GetRealHeight() CONST
{
	return RealHeight;
}


//+-----------------------------------------------------------------------------
//| Creates an empty single-colored texture
//+-----------------------------------------------------------------------------
BOOL TEXTURE::CreateEmpty(INT NewWidth, INT NewHeight)
{
	Clear();

	FileName = "EMPTY";
	Width = NewWidth;
	Height = NewHeight;
	RealWidth = NewWidth;
	RealHeight = NewHeight;

	Attach();

	return TRUE;
}

//+-----------------------------------------------------------------------------
//| Attaches the texture to the graphics class
//+-----------------------------------------------------------------------------
VOID TEXTURE::Attach()
{
	TextureReference.SetData(this);
	TextureReference.Attach(Graphics.TextureReferenceObject);
}


